#include <vector>
#include <glm/glm.hpp>
#include <GL/glfw.h>
#include "SimulationManager.h"

#define WINDOW_W 600
#define WINDOW_H 600

float ts = 0.03;

//A global simulation manager.
//This takes care of most boiler-plate code.
//If you only want to draw something, you only need to do three things:
//1) Create a display func with the function signerature
//	void funcname()
//2) In main, call 
//	sm.SetCallbackDisplay(funcname)
//  where funcname is the name of your draw function.
//3) In main, after the above function call, call
//	sm.Run();
//  This will start running the simulation.
// 
//  For a list of the callbacks the user can set, look at the "SetCallback..." functions 
//  in the SimulationManager header file.
//  Also, the GetCamera() method will get the camera and allow you to call methods which move
//	around the scene or rotate, etc.
SimulationManager sm(WINDOW_W, WINDOW_H);

//Display
//This function will be called as fast as possible, unlike the Update func.
//Only GL display code should be put in this section.  The screen
//is automatically cleared to white in the InitFrames() func, and the 
//glfwSwapBuffers() is called by the default EndFrames() function, so you only
//have to worry about actual drawing here.
void Display() {

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1, 1, -1, 1, 0.01, 10 );

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glTranslatef(0,0,-1);

	glColor3f(1.0,0.0,0.0);

	glBegin(GL_LINES);
	glVertex3f(0.0, 0.0, 0.0);
	glVertex3f(1.0, 0.0, 0.0);
	glEnd();
}

//Update
//This function will be called every timestep (ts).  The timestep can be
//set via the SetTimeStep method in SimulationManager. Put all non-drawing code
//here.
void KeyboardFunc( int key, int action ){

}

void Update(float ts) {
	//XXX
	//All update code goes here
	//...
	// Set

}

void Init(){
	
	sm.SetTimeStep(ts);
}

int main (int argc, char ** argv ){


	sm.SetCallbackDisplay(Display);
	sm.SetCallbackUpdate(Update);
	sm.SetCallbackLoadResources(Init);



	//XXX

	//Start simulation.
	sm.Run();

	return 0;
}